$address = @{}
$aliyunddnsCmd = Split-Path -Parent $MyInvocation.MyCommand.Definition
$aliyunddnsCmd += "/aliyunddns.exe"

while (1) {
    $newAddress = Get-NetIPAddress -InterfaceIndex 22 -AddressFamily IPv6 -SuffixOrigin Link -PrefixOrigin RouterAdvertisement | Select-Object IPAddress
    if ($newAddress.IPAddress -ne $address.IPAddress) {
        Write-Output "Update address..."
        Write-Output $newAddress.IPAddress
        & $aliyunddnsCmd $newAddress.IPAddress
        if ($?) {
            $address = $newAddress
        }
    }
    Start-Sleep -Seconds 10
}